import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {GlobalDataService} from "../service/global-data.service";
@Component({
  selector: 'app-page-a',
  templateUrl: './page-a.component.html',
  styles: [
  ]
})
export class PageAComponent implements OnInit {
  @Input() isFavorite: boolean = false;
  @Output() change = new EventEmitter()
  username:any = ''
  number = 0
  constructor(private globalDataService$: GlobalDataService) { }

  ngOnInit(): void {
    // console.log(this.globalData)
    // console.log(this.globalDataService$.username)
    this.username = this.globalDataService$.username;
    this.globalDataService$.globalVar.subscribe((d:any)=>{
      console.log("d",d)
      if(JSON.stringify(d) === '[]') return;
      this.username = d.username;
      this.number = d.number;
    })
  }

  onClick() {
    // this.globalData.username = '王五'
    // this.username = '王五'
    this.change.emit({ name: "张三" })
  }
}
